<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="${staticServer}/inc/style/main.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/page.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_client_tracking.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_client.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_student_read.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_client_reserve_form.css" />
<script src="${staticServer}/inc/js/jquery.js"></script>
<script src="${staticServer}/inc/js/datepicker.js"></script>
<script src="${staticServer}/inc/js/pageset.js"></script>
<script src="${staticServer}/inc/js/infopad.js"></script>
<script src="${staticServer}/inc/js/submitter.js"></script>
<script src="${staticServer}/js/web/consultant_client_state.js?1.4"></script>
<script src="${staticServer}/js/web/system_reserve_view.js?1.1"></script>
<script src="${staticServer}/js/web/consultant_client_check.js?1.5"></script>


</head>
<script>
 function click_scroll() {
  document.getElementById("anchor_scroll").click();
 }
 
$(function(){
	$("#btnSubmit").click( submit_form ); 
});

 
 function btnShow(obj){
	 var b = $(obj).siblings('.caption').parent().parent().find('p:not(:first)').visible();
	 var s = $(obj).siblings('.caption').parent().parent().parent().children();
	 var h = $(obj).siblings('.caption').parent();
	 var f = $(obj).siblings('.caption').parent().parent().parent().children('li:last');
	 var l = $("#btnSearchTracking");
	 
	 var remind = $(obj).siblings('.caption').parent().parent().find('#remind').val();
	 var sh = null;
	 if(remind!=""){
		 sh = $(obj).siblings('.caption').parent().parent().parent().children().children();
		}else{
		 sh = $(obj).siblings('.caption').parent().parent().parent().children().children().not("#re");
		}	
	 if(b == false){
			 sh.show();
			 s.show();
			 l.hide();
	 }else{
		 	sh.hide();
		 	h.show();
		 	f.hide();
		 	l.show();
	 }
	}

function submit_form()
{

	var data = {};

	// 客户资料

	// 跟踪数据
	data.keyname = $("#keyname").val();
	data.reserve_key = $("#reserve_key").val();
	var id = $("#traId").val();
	data.remark = $( "#remarks" ).html();
	data.protime = $("#proTime").val();
	data.target = $("#target").val();
	data.state = $("#state").val();
	
	var states = [];

  	$( "#statelist input:checked" ).each( function()
	{
		var val = $( this ).attr( "value" );
		states.push( val );
	} );
	
	data.states = states.join( "," );
	
	if((data.states).indexOf("138g5wfwm1mx")>=0 && data.protime ==""){
		alert("请设置定时提醒的时间。");
		return false;
	}
	
	if((data.states).indexOf("o3dpi9gzuol4")>=0 && data.target ==""){
		alert("请设置转交老师。");
		return false;
	}
	
	if( ( data.remark == "" || data.remark == "无" ) && data.invalid == 0 )
	{
		alert( "跟踪备注信息必须填写。" );
		return;
	}

	submitter.post( "${contextPath}/index/add_client_follow.json", data, function( d )
	{
		location.reload();
	}, "json" );
} 
 
var timeout = function(){
	var b = $(".odd1_row").visible();
	var a = $(".odd2_row").visible();
	if(b == false && a == false){
		$(".Zebra_DatePicker").css('z-index','9900');
		$(".odd1_row").show();
	}else{
		infopad.err( "“计划跟踪”和“已转交”不能同时设定。" );
		$(".odd1_row").hide();
	}
}	
var target = function(){
	var a = $(".odd2_row").visible();
	var b = $(".odd1_row").visible();
	if(a == false && b == false ){
		$(".odd2_row").show();
	}else{
		infopad.err( "“计划跟踪”和“已转交”不能同时设定。" );
		$(".odd2_row").hide();	
	}
}
 
</script>
<script type="text/javascript">
	function editSource(){
        $("#selectSource").show();
        $('#selectSource').change(function(){
			var  regionns = $(this).children('option:selected').val();
			var  client =$("#keyname").val();
            $.ajax({
                type: 'POST',
                url: 'system_ajaxedit_source.htm',
                data: {"regionns":regionns,"client":client},
                dataType:"text",
                success: function(data){
						if (data=="1"){
                            alert("更新成功!");
                            window.location.reload();
						}

                },
            });

        })
    }

</script>
<style type="text/css">
#statelist label {
	display: block;
	float: left;
	width: 120px;
	line-height:2.5;
}
</style>
<body>
	<div id="home_link">
		<ul>
			<li></li>
			<li>&gt;</li>
			<li>咨询师业务管理</li>
			<li>&gt;</li>
			<li class="current"></li>
		</ul>
	</div>
	<input type="hidden" id="keyname" value="${res.client}">
	<input type="hidden" id="reserve_key" value="${keyname}">
	<div id="container">
		<div id="title"></div>
		<table id="tbl_client">
			<tr class="fields">
				<th colspan="2">客户资料<a id="btn_detailed">（点击查看详细资料）</a></th>
			</tr>
			<tr>
				<th width="25%">客户姓名/称呼</th>
				<td width="75%"><span id="nickname" class="stress unit hand">${res.nickname}<#if client.invalid=="0"><em class="valid">(有效客户)<#else><em class="caption">(无效客户)</#if></em></span></td>
			</tr>
			<tr>
				<th>客户来源渠道</th>
				<td id="source" >${res.sourcens}
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <button type="button" class="submit"  onclick="editSource()">修改</button>
                    <select id="selectSource" style="display:none">
                        <option value="">-- 请选择来源 --</option>
                        <option value="jd2q59wq41ed" >百度推广</option>
                        <option value="kzpctoxsbclx" >百度推课</option>
                        <option value="251mokab1mtn" >百度网盟</option>
                        <option value="4D189169D77E" >百度信息流</option>
                        <option value="eyxl17rri7xu" >搜狗推广</option>
                        <option value="zgviq7wj9j0p" >360搜索推广</option>
                        <option value="F819056877F8" >神马推广</option>
                        <option value="ro9iszkillrp" >微信问卷</option>
                        <option value="k4jmt5lbp8ne" >400电话</option>
                        <option value="l0j9fitg3t94" >自然搜索</option>
                        <option value="02FAC12A4746" >百度糯米团购</option>
                        <option value="pmvk5vdc6ity" >商务通未知</option>
                        <option value="oymhrrozjjqq" >直接访问</option>
                        <option value="3DE37FFC1539" >百度咨询通</option>
                        <option value="l6xdybjjrcjc" >手机问卷</option>
                        <option value="nupd5182xxsl" >网站问卷</option>
                        <option value="UCinformationflow" >uc信息流</option>
                    </select>
				</td>
			</tr>
			<tr rel="hide">
				<th>关键字</th>
				<td id="keyword">${res.keyword}</td>
			</tr>
			<tr>
				<th>客户类别</th>
				<td id="category">${res.categoryns}</td>
			</tr>
			<tr rel="hide">
				<th>所在地</th>
				<td id="address">${res.province}</td>
			</tr>
			<tr>
				<th>联系电话</th>
				<td id="phone">
					<#if res.phlist??>
					<#list res.phlist as phlist>
						<#if phlist.name!=''>
						${phlist.name}：${phlist.phone}
						<#elseif phlist.guanxi!=''>
						${phlist.guanxi}：${phlist.phone}
						<#else>
						${phlist.phone}
						</#if>
					</#list>
					<#elseif res.phone!="" && res.phone?contains('[]')==false>
     						${res.phone}
					</#if>
     					</td>
			</tr>
			<tr rel="hide">
				<th>电子邮箱</th>
				<td id="email">${res.email}</td>
			</tr>
			<tr rel="hide">
				<th>QQ</th>
				<td id="qq">${res.qq}</td>
			</tr>
			<tr rel="hide">
				<th>IP地址</th>
				<td id="ip">${res.ip}</td>
			</tr>
		</table>
		<table id="tbl_student">
			<tr class="fields">
				<th colspan="2">待测评的学员<a id="btn_students">（点击查看客户名下所有学员）</a></th>
			</tr>
			<#if stuList??>
			<#list stuList as list>
			<tr rel="hide" class="even_row">
				<td colspan="2" id="studentlst">
					<ul>
					<li rel="a248d8a52d3749f198d740db5cab026bf9998f0c" class="selected">
					<p class="title">
						<span></span></p>
					<p>
						<b>性别</b>
						<span>${list.sex}</span>
					</p>
					<p>
						<b>年龄</b>
						<span>${list.age} 岁</span>
					</p>
					<p>
						<b>生日</b>
						<span><em class="caption">${list.birthday}</em></span></p>
					<p>
						<b>学校</b>
						<span>${list.school}</span>
					</p>
						<p><b>学员特征</b></p>
						<div class="content">${list.feature}</div>
					</li>
					</ul>
				</td>
			</tr>
			</#list>
			</#if>
		</table>
		<table id="tbl_reserve">
			<tr class="fields">
				<th colspan="2">预约表单</th>
			</tr>
			<tr>
				<th width="25%">预约发起人</th>
				<td width="75%"><span class="stress unit hand">${res.sponsor}</span></td>
			</tr>
			<tr>
				<th width="25%">预约登记日期</th>
				<td width="75%">${res.date}</td>
			</tr>
			<tr>
				<th width="25%">预约中心</th>
				<td width="75%"><span class="stress unit hand" id="region">${res.regionns}</span></td>
			</tr>
			<tr>
				<th width="25%">预约时间</th>
				<td width="75%"><span id="datetime">${res.time}</span></td>
			</tr>
			<tr>
				<th width="25%">接待老师</th>
				<td width="75%" id="receptionlst">
					<ul style="overflow: hidden;">
                    	<li id="duting" class="unit selected"><label class="stress">${res.receptioner}</label>，${res.jobns}</li>
					</ul>
					<p class="line"></p>
					<p class="caption">查询该中心可接待客户的咨询师名单，修改时会排除当前咨询师</p>
				</td>
			</tr>
			<tr>
				<th width="25%">预约状态</th>
				<td width="75%">当前状态：<span class="unit hand"><#if res.state=="1">待确认<#elseif res.state=="2">已出现<#elseif res.state=="3">已过期<#else>未出现</#if></span>
				<p id="statebx">
						目标状态：<select id="state"><option value="">-- 请选择状态 --</option><option value="1" title="客户需在预约时间内进一步确认">待确认</option><option value="2" title="客户已上门进行测评">已出现</option><option value="3" title="客户未出现，预约已过期">未出现</option></select><a id="btnAddTracking" onclick="addFloat('<#if reserve??>${reserve.client}</#if>')" style="display: none;">[ 客户跟踪 ]</a>
					</p> 
				</td>
			</tr>
			<tr>
				<th width="25%">短信通知
					<p class="caption">预约客户后的短信通知状态</p>
				</th>
				<td width="75%"><span class="stress unit hand" id="sms"><#if res.sms=="0">未发送短信通知<#else>已发送短信通知</#if></span>
					<p class="caption">当成功预约客户后，需要尽快将预约相关信息通知到客户。</p></td>
			</tr>
			<tr>
				<th width="25%">预约类型</th>
				<td width="75%"><span class="stress unit hand" id="non"><#if res.non=="0">测评类型<#else>非测评类型</#if></span>
					<p class="caption">非测评类型，一般为时间较短的业务类型，如缴费、续费、咨询等。</p></td>
			</tr>
			<#if res.notice?? && res.notice!="">
			<tr>
				<th width="25%">非测评类型提示</th>
				<td width="75%"><div id="notice">${res.notice}</div>
					<p class="caption">当作为非测评类型的预约时，此处填写的信息将显示在预约表中，而不会显示学员资料。</p></td>
			</tr>
			</#if>
			<tr>
				<th width="25%">预计需要时间</th>
				<td width="75%"><span class="stress unit hand" id="needtime">${res.needtime}小时</span>
					<p class="caption">预约客户上门接待时，所需要的大概时间，请根据该客户所携待测评学员数量进行调整</p>
					<p class="caption">接待时间默认 1.5 小时，将影响咨询师个人当天其它预约安排，之后只能缩短时间不能增加</p>
					<p class="caption">若是预约非测评，如缴费续费、咨询等请相应减少占用时间</p></td>
			</tr>
			<tr>
				<th width="25%" style="padding: 15px 10px 15px 10px;">其它备注情况</th>
				<td width="75%"><div id="remark">${res.remark}</div></td>
			</tr>
		</table>
		<div id="tralists">
		<table>
			<tbody><tr class="fields">
				<th colspan="4">历史跟踪记录<a id="btnSearchTracking" style="display:initial;">（查询历史跟踪记录）</a><a rel="btnadd" id="btnAddtrack" class="right" style="padding-right:20px">添加客户追踪</a></th>
			</tr>
			<#if traList?? >
				<#list traList?sort_by("id") as list>
					<tr class="even_row">
						<td colspan="4" class="trackinglst">
						<ul>
							<li>
							<p class="trackingtitle" style="display: block;">第${list_index+1}次跟踪记录<em class="caption">（负责人：${list.nickname}　日期：${list.createTime}）</em><a class="btnHidden" onclick="btnShow(this)">点击展开</a></p>
							<p class="trackingstate" style="display: none;"><b>客户状态</b>
							<span>
								<#if list.slist??>
									<#list list.slist as stalist>
										<a class="stateitem caption">${stalist.state}</a>
									</#list>
								<#else>
									<a class="stateitem caption"><#if list.state!="">${list.state}<#else>无变化</#if></a>
								</#if>
							</span></p>
							<p style="display: none;"><b>备注情况</b></p>
							<p style="display: none;" id="re"><b>时间提醒</b><input readonly="readonly" style="margin-left:5px;" value="${list.startTime}" class="DatePicker_Icon" type="text" name="remind" id="remind" size="15" value="" rel="DATE::Y-m-d" /></p>
							<div class="content" style="display: none;">${list.remark}</div>
							</li>
							<li style="display:none;">
							</li>
						</ul>
						</td>
					</tr>
				</#list>
			</#if>
		</tbody></table>
		</div>
		<div id="addtrack">
			<table><tr class="fields">
				<th colspan="2">今日客户跟踪记录（${.now}）</th>
			</tr>
			<tr class="even_row">
				<th width="25%">此次客户状态
					<p class="caption">状态可多选，不选择代表“无变化”</p>
				</th>
				<td width="75%" id="statelist">
					<label for="state_1" title="明确不参加"><input id="state_1" type="checkbox" value="qenzgu6wde3c">不参加</label>
					<label for="state_2" title="有较高意向和兴趣"><input id="state_2" type="checkbox" value="nhb8wyq1nda5">高意向</label>
					<label for="state_3" title="已经发送相关协议"><input id="state_3" type="checkbox" value="qyebkhp2x67y">已发协议</label>
					<label for="state_4" title="计划另行跟踪"><input id="state_4" type="checkbox" onclick="timeout()" value="138g5wfwm1mx">计划跟踪</label>
					<label for="state_5" title="已转交其它老师"><input id="state_5" type="checkbox" onclick="target()" value="o3dpi9gzuol4">已转交</label>
					<label for="state_6" title="已成功预约测评"><input id="state_6" type="checkbox" value="mldqhlrg1sad">已预约</label>
					<label for="state_7" title="已完成测评"><input id="state_7" type="checkbox" value="caoodurhkcl6">已测评</label>
					<label for="state_8" title="已缴费开始训练"><input id="state_8" type="checkbox" value="znouq0wygvbb">已缴费</label>
					<label for="state_9" title="已退费中止训练"><input id="state_9" type="checkbox" value="krm8s91foapx">已退费</label>
					<label for="state_11" title="预约成功的客户未出现"><input id="state_11" type="checkbox" value="n9fjwyx5w74g">未出现</label>
					<label for="state_12" title=""><input id="state_12" type="checkbox" value="n4f79h2giie6">意向一般</label>
					<label for="state_13" title=""><input id="state_13" type="checkbox" value="rym23z0aopkk">一直关机</label>
				<!--	<label for="state_14" title="无法接通"><input id="state_14" type="checkbox" value="pflp6f14pers">无法接通</label>
					<label for="state_15" title=""><input id="state_15" type="checkbox" value="ikslzv14e1dt">接通挂断</label>
					<label for="state_16" title=""><input id="state_16" type="checkbox" value="uj69ezpbh5a6">无人接听</label>
					<label for="state_17" title=""><input id="state_17" type="checkbox" value="x79wzgwvtlw4">空号</label>
					<label for="state_18" title=""><input id="state_18" type="checkbox" value="jvk1n2y542sw">无意向</label>
					<label for="state_19" title=""><input id="state_19" type="checkbox" value="27gflkc3y4j8">正在通话中</label>
					<label for="state_20" title=""><input id="state_20" type="checkbox" value="37nsij5vk6s9">有意向</label>
					<label for="state_21" title="不是当事人接电话，或者直接挂断"><input id="state_21" type="checkbox" value="w8j09zdfxhp1">未通</label>
					<label for="state_22" title="了解过，有印象，但不需要"><input id="state_22" type="checkbox" value="jezobexay0iq">了解&amp;不需要</label>
					<label for="state_23" title=""><input id="state_23" type="checkbox" value="t0aklt2bks96">孩子不在重庆</label>
					<label for="state_24" title=""><input id="state_24" type="checkbox" value="5cw0p5pk8brw">暂时没空</label>
					<label for="state_25" title=""><input id="state_25" type="checkbox" value="n0280meoxdhy">停机</label> -->
				</td>
			</tr>
			<tr class="odd1_row" style="display:none;">
				<th width="25%" style="padding: 15px 10px 15px 10px;">定时提醒</th> 
				<td width="75%"><div id="jhtime" contenteditable="true">
				<input type="text" name="pro_time" id="proTime" size="15" value="" rel="DATE::Y-m-d" />
				<p class="caption">需要计划在某日期跟踪时，设置“定时提醒”，当天会有消息提醒！</p></td>
			</tr>
			<tr class="odd2_row" style="display:none;" >
				<th width="25%" style="padding: 15px 10px 15px 10px;">转交目标
				<p class="caption">转交目标必须同样是咨询师</p>
				</th>
				<td width="75%"><div id="lodusername" contenteditable="true">
				<select id="target">
                	<option value="">-- 请选择目标 --</option>
                	<#if uList??>
						<#list uList as list>
                			<option value="${list.username}">${list.nickname}（${list.regions}-${list.departments}-${list.job}）</option>
                		</#list>
                	</#if>
                	</select>
				<p class="caption">成功转交后，你将无法在对该客户进行维护和跟踪，且从你个人客户资源中去除。</p></td>
			</tr>
			<tr class="odd_row">
				<th width="25%" style="padding: 15px 10px 15px 10px;">跟踪情况
					<p class="caption">客户咨询内容摘要，如“咨询问题”等</p>
				</th>
				<td width="75%"><div id="remarks" contenteditable="true">无</div></td>
			</tr>
		</table>
		</div>
		
		<div class="remark">
			<ul>
				<li><span class="title">注意事项：</span></li>
				<li>1、此处只提供预约信息详细的查看和参考，若要修改请登录相关帐号进行修改</li>
			</ul>
		</div>
		<div id="controlbar">
			<input id="btnSubmit" type="button" class="submit" value="保存客户咨询记录  " />
			<input id="btnCancel" type="button" class="submit" value="  返回列表  " onclick="history.back();"/>
		</div>
	</div>
</body>
</html>